<?php
/**
 * Single product
 * @package WOODGIFT
 * @author Mr Rony<mrtrandangtrinh@gmail.com>
 */
get_header();
?>
<div class="main-content row">
	<div class="col-md-9 main-fix single-product">
		<article class="product-title clearfix">
			<div id="breadcrumb" itemprop="breadcrumb">
				<?php get_sidebar('breadcrumb'); ?>
			</div>
		</article> <!--end of article.product-title-->
		<div class="info-content info-product">
			<?php while (have_posts()) : the_post(); ?>
			<?php global $product; ?>
			<div class="product-detail row">
				<div class="images col-md-5">
					<?php if (has_post_thumbnail()) : ?>
						<?php $image_title 		= esc_attr( get_the_title( get_post_thumbnail_id() ) ); ?>
						<?php $image_link  		= wp_get_attachment_url( get_post_thumbnail_id() );  ?>
						<?php $attachment_count	= count( $product->get_gallery_attachment_ids() );?>
						<?php $gallery = ($attachment_count > 0) ? 'prettyPhoto[product-gallery]' : 'prettyPhoto'; ?>
						<a class="woocommerce-main-image zoom" title="<?php echo $image_title; ?>" rel="<?php echo $gallery; ?>" href="<?php echo $image_link; ?>" itemprop="image">
							<?php the_post_thumbnail('view-product'); ?>
						</a>
					<?php endif; ?>
				</div>
				<div class="summary entry-summary col-md-7">
					<h1 class="product_title entry-title"><?php the_title(); ?></h1>
					<ul class="info">
						<li><?php _e('Nhà sản xuất:'); ?>
                        	<?php
								echo $product->get_categories( ', ', '' . _n( '', '', sizeof( get_the_terms( $post->ID, 'product_cat' ) ), 'woocommerce' ) . ' ', '' );
                            ?>
                        </li>
						<li itemprop="productID" class="sku_wrapper">
							<?php _e('Mã sản phẩm:'); ?>
							<?php if ( $product->is_type( array( 'simple', 'variable' ) ) && get_option( 'woocommerce_enable_sku' ) == 'yes' && $product->get_sku() ) : ?>
							<span class="sku">
								<?php echo $product->get_sku(); ?>
							</span>
							<?php endif; ?>
						</li>
						<li>
							<?php $status = ($product->is_in_stock()) ? 'Còn hàng' : 'Hết hàng'; ?>
							<?php _e('Tình trạng:'); ?><span><?php echo $status; ?></span>
						</li>
					</ul>
					<?php if ( $product->is_in_stock() ) : ?>
						<?php $price_html = $product->get_price(); ?>
						<?php if ($price_html) : ?>
							<span class="price" itemprop="price">
								<?php _e("Giá: ") ?>
								<?php echo number_format($price_html, 0, '.' , '.') . '.000 VNĐ'; ?>
							</span>
						<?php endif; ?>
						<div class="cart-shopping">
							<?php $link = $product->add_to_cart_url(); ?>
							<?php $label = apply_filters('add_to_cart_text', __('Thêm vào giỏ')); ?>
							<?php $link = add_query_arg('variation_id', $variation->variation_id, $link); ?>
							<?php printf('<a href="%s" rel="nofollow" data-product_id="%s" class="btn btn-success add_to_cart_button product_type_%s">%s</a>', esc_url($link), $product->id, $product->product_type, $label); ?>
						</div>
					<?php else : ?>
						<h1 class="status-product"><?php _e("Đã bán hết"); ?></h1>
					<?php endif; ?>
					<div class="social-network">
						<!-- AddThis Button BEGIN -->
						<div class="addthis_toolbox addthis_default_style share">
							<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=300&amp;pubid=ra-507e234541de584e"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a>
							<!-- AddThis Button END -->
						</div>
						<!-- AddThis Button END -->
						<div class="fb-like" data-href="<?php the_permalink(); ?>" data-width="335" data-show-faces="true" data-send="false"></div>
					</div>
				</div>
			</div>
			
			<?php $tabs = apply_filters( 'woocommerce_product_tabs', array() ); ?>
			<?php if ( ! empty( $tabs ) ) : ?>
				<div class="woocommerce-tabs">
					<ul class="tabs clearfix">
						<?php foreach ( $tabs as $key => $tab ) : ?>
							<li class="<?php echo $key ?>_tab">
								<a href="#tab-<?php echo $key ?>"><?php echo apply_filters( 'woocommerce_product_' . $key . '_tab_title', $tab['title'], $key ) ?></a>
							</li>
						<?php endforeach; ?>
					</ul>
					<?php foreach ( $tabs as $key => $tab ) : ?>
						<div class="panel entry-content" id="tab-<?php echo $key ?>">
							<?php call_user_func( $tab['callback'], $key, $tab ) ?>
						</div>
					<?php endforeach; ?>
				</div>
			<?php endif; ?>
			<?php endwhile; ?>
		</div>
	</div>
	<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
